package com.zhuss.core.diss;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.zhuss.bean.bo.core.diss.CreateDissBo;
import com.zhuss.bean.bo.core.diss.DeleteDissBo;
import com.zhuss.bean.bo.core.diss.UpdateDissBo;
import com.zhuss.bean.bo.core.diss.StartDissBo;
import com.zhuss.bean.bo.core.diss.StopDissBo;
import com.zhuss.common.OperateService;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;

/**
 * @description: 吐槽操作的Service
 * @author: zhushanshuo
 * @create: Tue Feb 02 15:22:08 CST 2021
 **/
@Component("dissOperateService")
public class DissOperateService implements OperateService<Void, Object> {
	
	@Autowired
	@Qualifier("dissCreate")
	private Processor<Object, CreateDissBo> dissCreate;
	
	@Autowired
	@Qualifier("dissUpdate")
	private Processor<Object, UpdateDissBo> dissUpdate;
	
	@Autowired
	@Qualifier("dissDelete")
	private Processor<Object, DeleteDissBo> dissDelete;
	
	@Autowired
	@Qualifier("dissStart")
	private Processor<Object, StartDissBo> dissStart;
	
	@Autowired
	@Qualifier("dissStop")
	private Processor<Object, StopDissBo> dissStop;
	
	
	/**
	 * 创建
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
	public Void create(Object param) throws DzcxException {
		
		CreateDissBo bo = (CreateDissBo) param;
		
		dissCreate.process(bo);
		
		return null;
	}
    
	/**
	 * 修改
	 */
	@Override
    @Transactional(rollbackFor = Exception.class)
    public Void update(Object param) throws DzcxException {
    	
		UpdateDissBo bo = (UpdateDissBo) param;
		
		dissUpdate.process(bo);
		
    	return null;
    }
	
	/**
	 * 删除
	 */
	@Override
	@Transactional(rollbackFor = Exception.class)
	public Void delete(Object param) throws DzcxException {
		
		DeleteDissBo bo = (DeleteDissBo) param;
		
		dissDelete.process(bo);
		
		return null;
	}
	
	/**
	 * 启用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void start(Object param) throws DzcxException {
		
		StartDissBo bo = (StartDissBo) param;
		
		dissStart.process(bo);
		
		return null;
	}
	
	/**
	 * 停用
	 */
	@Transactional(rollbackFor = Exception.class)
	protected Void stop(Object param) throws DzcxException {
		
		StopDissBo bo = (StopDissBo) param;
		
		dissStop.process(bo);
		
		return null;
	}
	
}

